 package com.oanda.blackberry.restapi;
 
 import java.util.Vector;
 
 public class TradeListResponse extends PositionsListResponse
 {
   long id;
   int units;
   String dir;
   String symbol;
   double price;
   long time;
   double stop_loss;
   double take_profit;
   double trailing_stop;
 
   public TradeListResponse()
   {
   }
 
   public TradeListResponse(long id, int units, String dir, String symbol, long time, double price, double stop_loss, double take_profit, double trailing_stop)
   {
     this.id = id;
     this.units = units;
     this.dir = dir;
     this.symbol = symbol;
     this.time = time;
     this.price = price;
     this.stop_loss = stop_loss;
     this.take_profit = take_profit;
     this.trailing_stop = trailing_stop;
   }
 
   public String getDir() {
     return this.dir;
   }
 
   public long getId() {
     return this.id;
   }
 
   public double getPrice() {
     return this.price;
   }
 
   public double getStop_loss() {
     return this.stop_loss;
   }
 
   public String getSymbol() {
     return this.symbol;
   }
 
   public double getTake_profit() {
     return this.take_profit;
   }
 
   public long getTime() {
     return this.time;
   }
 
   public double getTrailing_stop() {
     return this.trailing_stop;
   }
 
   public int getUnits() {
     return this.units;
   }
 
   public static void sort(TradeListResponse[] r)
   {
     alphaSort(r);
   }
 
   public static void bubbleSort(TradeListResponse[] arr)
   {
     boolean swapped = true;
     int j = 0;
 
     while (swapped) {
       swapped = false;
       j++;
       for (int i = 0; i < arr.length - j; i++)
         if (arr[i].getId() > arr[(i + 1)].getId()) {
           TradeListResponse tmp = arr[i];
           arr[i] = arr[(i + 1)];
           arr[(i + 1)] = tmp;
           swapped = true;
         }
     }
   }
 
   public static void alphaSort(TradeListResponse[] arr)
   {
     Vector sorted = new Vector();
 
     sorted.addElement(arr[0]);
     for (int i = 1; i < arr.length; i++)
     {
       for (int j = 0; j < i; j++)
       {
         if (((TradeListResponse)sorted.elementAt(j)).getSymbol().compareTo(arr[i].getSymbol()) > 0)
         {
           sorted.insertElementAt(arr[i], j);
           break;
         }
         if (j != i - 1)
           continue;
         sorted.addElement(arr[i]);
         break;
       }
     }
 
     for (int i = 0; i < arr.length; i++)
     {
       arr[i] = ((TradeListResponse)sorted.elementAt(i));
     }
   }
 
   public static void bubbleSort(int[] arr)
   {
     boolean swapped = true;
     int j = 0;
 
     while (swapped) {
       swapped = false;
       j++;
       for (int i = 0; i < arr.length - j; i++)
         if (arr[i] > arr[(i + 1)]) {
           int tmp = arr[i];
           arr[i] = arr[(i + 1)];
           arr[(i + 1)] = tmp;
           swapped = true;
         }
     }
   }
}

